package cn.kgm.orderObserver;

import cn.kgm.orderObserver.pojo.PlaceOrderMessage;

import java.util.ArrayList;
import java.util.List;

public abstract class OrderSubject {

    final List<OrderObserver> obs = new ArrayList<>();

    public void addObs(OrderObserver ob){
        obs.add(ob);
    }

    public void deleteObs(OrderObserver ob){
        obs.remove(ob);
    }

    public void notifyObservers(PlaceOrderMessage placeOrderMessage){
        obs.forEach(obj->{
            obj.afterPlaceOrder(placeOrderMessage);
        });
    }
}
